/**
 * 
 */
package GraphicView;

import ikeuilib.TableParam;

import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

import GraphicView.GraphicView.XAxisDrawProperty;
import GraphicView.GraphicView.YAxisDrawProperty;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * @author Toshiharu Ikeda <ikeda.104@gmail.com>
 *
 */
public class DlgXYAxisDrawProperty extends JDialog {
	private TableParam table;
	public boolean Ok = false;
	public DlgXYAxisDrawProperty() {
		setTitle("XY Axis display property");
		
		
		getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.SOUTH);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		
		JButton btnOK = new JButton("OK");
		btnOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Ok = true;
				dispose();
			}
		});
		panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		panel.add(btnCancel);
		panel.add(btnOK);
		
		JScrollPane scrollPane = new JScrollPane();
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		
		table = new TableParam(new TableParam.MyModel());
		scrollPane.setViewportView(table);
		
		setModalityType(JDialog.ModalityType.TOOLKIT_MODAL);
		setSize(300,400);
	}
	
	public void setData(GraphicView.YAxisDrawProperty p){
		table.addValue("Draw Center value" ,p.DrawCenter);
		table.addValue("Draw Control handle" ,p.DrawControlHandle);
		table.addValue("Label number max" ,p.LabelNumberMax);
		table.addValue("Font point max" ,p.LabelFontMax);
		table.addValue("Font point min" ,p.LabelFontMin);
		
		TableColumn col = table.getColumnModel().getColumn(0);
		col.setMinWidth(120);
	}
	
	public void getData(GraphicView.YAxisDrawProperty p){
		p.DrawCenter 		= (Boolean)table.getValue(0);
		p.DrawControlHandle = (Boolean)table.getValue(1);
		p.LabelNumberMax 	= (Integer)table.getValue(2);
		p.LabelFontMax 		= (Integer)table.getValue(3);
		p.LabelFontMin 		= (Integer)table.getValue(4);
	}

	/**
	 * @param xAxisProp
	 */
	public void setData(GraphicView.XAxisDrawProperty xAxisProp) {
		table.addValue("Draw Clock",xAxisProp.DrawClock);
		table.addValue("Draw XBar",xAxisProp.DrawXBar);

	}

	/**
	 * @param xAxisProp
	 */
	public void getData(GraphicView.XAxisDrawProperty xAxisProp) {
		xAxisProp.DrawClock = (Boolean)table.getValue(5);
		xAxisProp.DrawXBar = (Boolean)table.getValue(6);
	}
	
}
